package com.ruoyi.system;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.ruoyi.common.security.annotation.EnableCustomConfig;
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Optional;
/**
 * 系统模块
 * 
 * @author ruoyi
 */
@EnableCustomConfig
@EnableRyFeignClients
@SpringBootApplication
@Slf4j
public class RuoYiSystemApplication
{
    public static void main(String[] args)throws UnknownHostException {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(RuoYiSystemApplication.class, args);
        System.out.println("(♥◠‿◠)ﾉﾞ  系统模块启动成功   ლ(´ڡ`ლ)ﾞ  \n" +
                " .-------.       ____     __        \n" +
                " |  _ _   \\      \\   \\   /  /    \n" +
                " | ( ' )  |       \\  _. /  '       \n" +
                " |(_ o _) /        _( )_ .'         \n" +
                " | (_,_).' __  ___(_ o _)'          \n" +
                " |  |\\ \\  |  ||   |(_,_)'         \n" +
                " |  | \\ `'   /|   `-'  /           \n" +
                " |  |  \\    /  \\      /           \n" +
                " ''-'   `'-'    `-..-'              ");
        // 获取本地 ip 地址
        String ip = InetAddress.getLocalHost().getHostAddress();
        // 获取服务配置文件，name、port、以及全局服务路径
        Environment env = applicationContext.getEnvironment();
        String name = env.getProperty("spring.application.name");
        String port = env.getProperty("server.port");
        String path = Optional.ofNullable(env.getProperty("server.servlet.context-path")).orElse("");
        // 打印输出
        log.info("\n----------------------------------------------------------\n\t" +
                "应用模块 " + name +" 启动成功 URLs:\n\t" +
                "本地访问网址: \t\thttp://localhost:" + port + path + "\n\t" +
                "IP 访问网址: \t\thttp://" + ip + ":" + port + path + "\n\t" +
                "----------------------------------------------------------");
    }
}
